home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / postopen.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  6KB  |  204 lines

  1.  /********************************************************
  2.  *                                                       *
  3.  *                 POSTOPEN                              *
  4.  *                                                       *
  5.  *  Function : Search for the RCB in the "wait" queue and*
  6.  *             process it then.                          *
  7.  *                                                       *
  8.  *  Input  : the RQB which has code 0x05ff and the user  *
  9.  *           correlator.                                 *
  10.  *  Output : the RCB has been deleted from the "wait"    *
  11.  *           queue and response to TP with "return" code *
  12.  *           has been sent.                              *
  13.  *                                                       *
  14.  *                                                       *
  15.  * CopyRight 1995. Nicholas Poljakov all rights reserved.*
  16.  *                                                       *
  17.  ********************************************************/
  18. #include <include.h>
  19. #include <rcb.h>
  20. #include <repass.h>
  21. #include <common.h>
  22. #include <psp.h>
  23. #include <rpl.h>
  24. #include <nib.h>
  25. #include <lucb.h>
  26. #include <scb.h>
  27. #include <string.h>
  28. #include <state1.h>
  29. #include <malloc.h>
  30. #include <drcb.h>
  31. #include <prefix.h>  /* 27.11.92 */
  32.  
  33. struct psp psp_ini;
  34. int sk_r_wt(void *);
  35. int SendBlock(void *, void *);
  36. int setrc(void *, void *);
  37. int sendhsf(void *);
  38. int sendhs(void *);
  39. int sendbm(void *, void *);
  40. int sendat(void *);
  41. int rtsend(void *);
  42. unsigned long rmfmh5(void *, void *);
  43. int recwait(void *);
  44. int rcvru(void *, void *);
  45. int rcvhs(void *, void *, void *, void *);
  46. int ralloc(void *, void *);
  47. int psrm(int, void *, void *);
  48. int ps_conv(int, void *);
  49. int proterr(void *, unsigned long);
  50. int preptrcv(void *, void *);
  51. int post_rcb(void *);
  52. struct repass *postopen(void *);
  53. int phsrec(void *);
  54. int pfmh5(void *);
  55. int opndst(void *);
  56. int obtsess(void *, unsigned char);
  57. int Lrf_handler(void *);
  58. int get_sess(void *, void *);
  59. int get_attr(void *);
  60. int fsm_error(unsigned char, void *);
  61. int fsm_conv(unsigned char, unsigned char, void *);
  62. int flush (void *);
  63. int dcp(void *);
  64. int dealloc(void *);
  65. int crtp(void *);
  66. int conv(void *);
  67. int chkparm(void *, void *);
  68. int check_end(unsigned int, void *);
  69. struct rqb *call_appl(void *);
  70. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  71. unsigned long attltck(void *);
  72. unsigned long attacheck(void *);
  73. char *cgetmem(int, int);
  74. int sendhsf(void *);
  75. int opndst(void *);
  76. int alloc_rcb(void *, void *);
  77. int allocate(void *);
  78. int clsdst(void *);
  79.  
  80. extern struct lucb lu6;
  81.  
  82. struct repass *postopen(p_rqb)
  83. struct rqb *p_rqb;
  84. {
  85.     struct rcb *p_rcb;
  86.     struct rcb *temp_rcb;
  87.     struct repass *p_rep;
  88.     struct com *p_com;
  89.     struct scb *p_scb;
  90.     struct scb *temp_scb;
  91.     struct rpl *p_rpl;
  92.     struct nib *p_nib;
  93.     int i;
  94.     struct drcb d_rcb;
  95.     struct scb *t_scb;    /* 27.11.92 */
  96.     struct scb *t1_scb;   /* 27.11.92 */
  97.     struct prefix *prf;   /* 27.11.92 */
  98.     unsigned long s_crl;
  99.     char *p;
  100.     unsigned char p1;
  101.  
  102. #if OS_TYPE == 1
  103. /*********  Trace facility **********/
  104. unsigned int rtype;   /* type of record */
  105. unsigned int pnum;    /* point number */
  106. char pname[8];        /* name of module */
  107. char *drec;       /* record for dump */
  108. int  lenr;            /* record length */
  109.  
  110. rtype = INPROC;
  111. strcpy(pname, "postopn");
  112. pnum = 1;
  113. drec = p_rqb;
  114. lenr = 16;
  115. gtf(rtype, pname, pnum, drec, lenr);
  116. /***********************************/
  117. #endif
  118.  
  119.     p = (char *)&s_crl;
  120.     for (i = 0; i < 4; i++) {
  121.         p[i] = p_rqb -> th.ra.wa.hh.rswa[i];
  122.     }
  123.  
  124.     if ((temp_rcb = psp_ini.wait_chain) == NULL) {
  125.         return (NULL);
  126.     }
  127.  
  128.     while (temp_rcb != NULL) {
  129.         if (temp_rcb -> sess_corl == s_crl) {
  130.             goto pRCB;
  131.         }
  132.         temp_rcb = temp_rcb -> next;
  133.     }
  134.     return (NULL); /* RCB not found ! */
  135.  
  136. pRCB:
  137.     /* RCB found */
  138.     p_rcb = temp_rcb;
  139. #if OS_TYPE == 1     /* Unix V */
  140.     del_wait(p_rcb); /* Delete RCB from the "wait" qeue */
  141. #endif
  142. #if OS_TYPE == 0     /* MS-DOS */
  143.     post_rcb(p_rcb); /* post rcb if it was found in the wait queue */
  144. #endif
  145.     p_rcb -> sess_corl = p_rqb -> th.ra.wa.hh.hscb; /* Save CID */
  146.     p_rcb -> conv_state = SEND;  /* Initial state for primary LU */
  147.     p_scb = p_rcb -> p_scb;
  148.     p_rpl = p_scb -> p_rpl;
  149.     p_rpl -> arg = p_rqb -> th.ra.wa.hh.hscb; /* Save CID in RPL*/
  150.     p_rep = p_rcb -> verb_ptr;
  151.     p_com = p_rcb -> verb_ptr;
  152.     p_rep -> complete = 0; /* no retry */
  153.  
  154.     /* Test return code for OPNDST request */
  155.  
  156.     p1 = p_rqb -> th.ra.code & 0x3c; /* select return code from RQB*/
  157.     if (p1 != OK) {
  158.         p1 = ALLOC_FAIL_NO_RETRY;
  159.         fsm_error(p1, p_rcb);
  160.         p_com -> prim_rc = ALLOCATION_FAILURE_NO_RETRY;
  161.         prf = p_rcb -> first_out;
  162.     buffmng('D',prf,&((*p_rcb).first_out),p_rcb,0,0,0); /* FMH */
  163.     d_rcb.p_rcb = p_rcb;
  164.     d_rcb.p_tcb = p_rcb -> p_tcb;
  165.         psrm(DEALLOCATE_RCB, &d_rcb, 0);
  166.  
  167.         /*
  168.          * Free the SCB and the related blocks (RPL, NIB)
  169.          */
  170.         if ((temp_scb = p_scb -> prev) == NULL) {
  171.                 /*
  172.                  * first SCB in chain.
  173.                  */
  174.                 lu6.scb_list = p_scb -> next;
  175.         }
  176.         else
  177.                 temp_scb -> next = p_scb -> next;
  178.  
  179.         p_nib = p_rpl -> p_nib;
  180.         if (p_nib != NULL) {
  181.            free( p_nib );
  182.         }
  183.         free( p_rpl );
  184.         free( p_scb );
  185.         p_rcb -> p_scb = NULL;
  186.         lu6.cur_sess--;
  187.  
  188.         return (p_com);
  189.     }
  190.     if (p_rcb -> first_out == NULL) {
  191.         return (NULL);
  192.     }
  193.     /*
  194.     if ((i = sendhs(p_rcb)) == OK) {
  195.         p_com -> prim_rc = OK;
  196.     }
  197.     else
  198.             p_com -> prim_rc = ALLOCATION_FAILURE_RETRY;
  199.     */
  200.     p_com -> prim_rc = OK;
  201.  
  202.     return (p_com);
  203. }
  204.